package acm;

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class 字串统计 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int l=in.nextInt();
        in.nextLine();
        String s = in.nextLine();
        Map<String,Integer> map = new HashMap<String,Integer>();
        int maxvalue = 0;
        String maxstr = "";
        for (int i=0;i<s.length()-l+1;i++){
            for (int j=i+l;j<s.length();j++){
                String str = s.substring(i,j);
                if (map.containsKey(str)){
                    int value = map.get(str);
                    value++;
                    if (value>maxvalue){
                        maxstr=str;
                        maxvalue=value;
                    }
                    else if (maxvalue==value){
                        if (maxstr.length()<str.length()){
                            maxstr=str;
                        }
                    }
                    map.put(str, value) ;
                }
                else {
                    map.put(str,0);
                }
            }
        }
        System.out.print(maxstr);
    }
}
